package com.example.preview.activity;


import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.example.preview.R;
import com.example.preview.loader.HugeImageRegionLoader;
import com.example.preview.loader.TileDrawable;
import com.example.preview.view.PinchImageView;

public class HugeActivity extends AppCompatActivity {

    private TileDrawable mTileDrawable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_huge);

        final PinchImageView pinchImageView = (PinchImageView) findViewById(R.id.pic);
        pinchImageView.post(() -> {
            mTileDrawable = new TileDrawable();
            mTileDrawable.setInitCallback(() -> pinchImageView.setImageDrawable(mTileDrawable));
            mTileDrawable.init(new HugeImageRegionLoader(HugeActivity.this, Uri.parse("file:///android_asset/card.png")), new Point(pinchImageView.getWidth(), pinchImageView.getHeight()));
        });
    }

    @Override
    protected void onDestroy() {
        if (mTileDrawable != null) {
            mTileDrawable.recycle();
        }
        super.onDestroy();
    }
}